#include <iostream>
#include <stack>
#include <unordered_map>
#include <string>

bool checkBrackets(const std::string& s) {
    std::stack<char> stack;
    std::unordered_map<char, char> mapping = {{')', '('}, {'}', '{'}, {']', '['}, {'>', '<'}};
    for (char c : s) {
        if (mapping.find(c) == mapping.end()) {
            stack.push(c);
        } else {
            if (stack.empty() || stack.top() != mapping[c]) {
                return false;
            }
            stack.pop();
        }
    }
    return stack.empty();
}

int main() {
    std::string sequence;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> sequence;
    std::cout << std::boolalpha << checkBrackets(sequence) << std::endl;
    return 0;
}
